<script setup lang="ts">
import { watch, ref } from 'vue'
import { articles } from '../api'
import type { articlesApiresults } from '../types/channels'
const props = defineProps<{
  currId: number
}>()
// articles
const list = ref<articlesApiresults[]>([])
const getData = async () => {
  const res = await articles(props.currId)
  list.value = res.data.results
  console.log(res.data.results)
}
watch(
  () => props.currId,
  () => {
    getData()
  }
)
</script>

<template>
  <div class="article-list">
    <div class="article-item" v-for="i in list" :key="i.art_id">
      <p class="title">
        {{ i.title }}
      </p>
      <img
        v-for="(item, index) in i.cover.images"
        :key="index"
        class="img"
        :src="item"
        alt=""
      />
      <div class="info">
        <span>{{ i.aut_name }}</span>
        <span>{{ i.comm_count }}评论</span>
        <span>{{ i.pubdate }}</span>
      </div>
    </div>
  </div>
</template>
